#ifndef _H_WOP_STRING_PROXY_H_
#define _H_WOP_STRING_PROXY_H_

#include "all_entries.h"
/**
	hyt - 09/09/28 新增WOP_String_Proxy
**/

class WOP_String_Proxy : public WOP_Entry{
private:
	string _val;
	WOP_String_Entry* _en;
	WOP_String_Proxy(){}
public:
	WOP_String_Proxy(WOP_String_Entry* en){
		this->_en = en;
		init(en->getName(),en->getParent());
	}
	string* getStrValAddr() { return &_val ; }
	WOP_String_Entry* getEntry(){return this->_en;}
	string getTypeStr() { return std::string("string"); }

	virtual void setVal(string s){
		this->_en->setVal(s);
		this->_value = s;
	}
	virtual void setAddr(string s){
		this->_en->setAddr(s);
		this->_addr = s;
	}
	virtual void setVarType(string s){
		this->_en->setVarType(s);
		this->_vartype = s;
	}
	/* added by ypc */
	virtual void setName(string name) {	
		this->_en->setName(name);
		this->_name = name ;
	}
	virtual void setFrom(WOP_Entry *s){		
		this->_en->setFrom(s);
		this->_from = s;
	}
	virtual void setDescentFrom(WOP_Entry * from){
		this->_en->setDescentFrom(from);
		if (from != NULL) {
			if (from->isTop()) 
				this->_descentfrom = from ;
			else  
				this->_descentfrom = from->getDescentFrom();
		}
	}
	virtual void setTop(bool t){		
		this->_en->setTop(t);
		_top = t;
	}
	virtual void setUpdated(bool t){		
		this->_en->setUpdated(t);
		this->_updated = t;
	}
	virtual void setChanged(bool t){		
		this->_en->setChanged(t);
		this->_changed = t;
	}
	virtual void setScope(bool t){		
		this->_en->setScope(t);
		this->_inscope = t;
	}

	virtual bool update(){
		bool real_en_update;
		real_en_update = _en->update();
		if(real_en_update){
			this->_val = *(_en->getStrValAddr());
		}
		this->_changed = real_en_update;
		return this->_changed;
	}
	void updateProxyValue(string s){
		string value ;
		_value = s ;		
	}
	virtual void updateRealValue(string s) {
		_en->updateRealValue(s);
		_val = *(_en->getStrValAddr());
	}
};
#endif